#ifndef SERVER_H
#define SERVER_H

#include <QObject>
#include <QTcpServer>
#include <QTimer>
#include "../common/singleton.h"
/**
 * @brief The Server class
 * @brief 管理建立连接
 */
class Server : public QObject
{
    Q_OBJECT

    friend class SingleTon<Server>;
    explicit Server(QObject *parent = nullptr);
    Server(const Server&) = delete ;
    Server(Server&&) = delete ;
public:
    ~Server();

    bool listen(const QString& addr, qint16 port);

    QTimer *heartBeatTimer;

signals:
    void timeout();

private slots:
    void onNewConnection();

private:
    QTcpServer* server;

};

#endif // SERVER_H
